<footer id="footer">
    <div class="container">
      <div class="row">
        <span id="icp" class="pull-left gray-link">
            © 2005－2015 wowshi.com, all rights reserved
        </span>
        <a href="javascript:;" style="display: none;"></a>
        <span class="pull-right">
            <a href="javascript:;">关于哇礼</a>
            · <a href="javascript:;">在哇礼工作</a>
            · <a href="javascript:;">联系我们</a>
            · <a href="javascript:;">免责声明</a>
            · <a href="javascript:;">帮助中心</a>
            · <a href="javascript:;">移动应用</a>
        </span>       
      </div>
    </div>
  </footer>
  <!-- 登录model开始 -->
  <div class="modals">
    <div class="modal fade" id="login-modal">
        <div class="modal-dialog_wrapper">
            <div class="modal-dialog modal-dialog--front modal-dialog--signin">
                <div class="modal-content">
                    <button class="close" data-dismiss="modal" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                    <div class="modal-body">
                        <form id="login_form" class="simple_form new_user" action="{:U('user/Index/login')}" accept-charset="UTF-8" data-remote="true" method="post" novalidate="true">
                            <input name="utf8" type="hidden" value="✓">
                            <legend>登录</legend>
                            <div class="form-main">
                                <div class="form-group col-sm-6">
                                    <label class="sr-only">邮件地址</label>
                                    <input required="required" placeholder="邮件地址" class="form-control" data-message-error="邮箱格式错误" type="email" name="user[email]" id="login_email" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="sr-only">密码</label>
                                    <input required="required" placeholder="密码" class="form-control" type="password" name="user[password]" id="login_password" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <input type="hidden" name="redirect_from" id="redirect_from">
                            </div>
                            <div class="form-group addon clearfix">
                                <div class="checkbox pull-left" id="remember_me">
                                    <label>
                                        <input name="user[remember_me]" type="hidden" value="0">
                                        <input type="checkbox" value="1" checked="checked" name="user[remember_me]" id="user_remember_me">记住我</label>
                                </div>
                                <a class="pull-right" data-toggle="modal" data-dismiss="modal" href="#find_password_modal">
                                <i class="fa fa-question-circle"></i>忘记密码？</a>
                            </div>
                            <div class="form-group form-results hidden" id="sign_in_alert_field">用户名或密码错误，请重新输入</div>
                            <div class="form-group form-actions">
                                <input type="submit" name="commit" value="登录" class="btn btn--blue_light" data-category="user" data-action="login" data-label="email">
                            </div>
                        </form>
                        <section class="auth">
                            <h6>使用社交账号登录</h6>
                            <p>
                            <a class="btn btn--icon btn--blue_light" title="用微信登录" data-category="user" data-action="login" data-label="wechat" href="/users/auth/wechat_web?state=%2Fdiscover"><i class="fa fa-weixin"></i></a>
                            <a class="btn btn--icon btn--blue_light" title="用微博登录" data-category="user" data-action="login" data-label="weibo" href="/users/auth/weibo?state=%2Fdiscover"><i class="fa fa-weibo"></i></a>
                            </p>
                        </section>
                        <footer class="section-footer"><a class="modal-flipper" href="#">注册<em class="logo">猫耳</em><i class="fa fa-angle-right"></i></a></footer>
                    </div>
                </div>
            </div>
            <div class="modal-dialog modal-dialog--back modal-dialog--signup">
                <div class="modal-content">
                    <button class="close" data-dismiss="modal" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                    <div class="modal-body">
                        <form id="signup_form" class="simple_form new_user" action="{:U('User/Index/register')}" accept-charset="UTF-8" data-remote="true" method="post" novalidate="true">
                            <input name="utf8" type="hidden" value="✓">
                            <legend>注册</legend>
                            <div class="form-main">
                                <div class="form-group col-sm-6">
                                    <label class="sr-only" for="user_name">昵称</label>
                                    <input placeholder="用户名（少于 3~20 个字符）" class="form-control" required="required" maxlength="20" data-message-error="用户名必须介于介于 3~20个字符" size="20" type="text" value="" name="user[user_name]" id="user_name" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="sr-only" for="user_email">邮件地址</label>
                                    <input placeholder="邮件地址" class="form-control" required="required" data-message-error="邮箱格式错误" type="email" name="user[email]" id="user_email" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <div class="clearfix"></div>
                                <div class="form-group col-sm-6">
                                    <label class="sr-only" for="user_password">密码</label>
                                    <input placeholder="密码（至少 6 个字符）" class="form-control" required="required" minlength="6" data-message-error="密码至少 6 个字符" type="password" name="user[password]" id="user_password" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <div class="form-group col-sm-6 signup_form-captcha">
                                    <label class="sr-only" for="captcha">验证码</label>
                                    <div class="input-group">
                                        <input type="text" name="captcha" id="captcha" autocomplete="off" required="required" class="form-control" data-parent=".form-group" placeholder="输入验证码" data-event="validate">
                                        <input type="hidden" name="captcha_key" id="simple-captcha-hidden-field-simple_captcha-28e145c6347" value="28e145c634754b73369a62a7156e795d0f880b66">
                                        <div class="input-group-addon" style="padding:0px;">
                                            <a rel="nofollow" title="换一张" data-remote="true" href="javascript:;" onclick="this.children[0].src='__ROOT__/index/get_code?id='+Math.random()+1"><img src="__ROOT__/index/get_code" id="simple_captcha-28e145c6347" alt="captcha" class="js-lazy" data-original=""  style="visibility: visible; display: inline;width:100px;height:44px;"></a>
                                        </div>
                                    </div>
                                    <ul class="help-block"></ul>
                                </div>
                            </div>
                            <div class="form-group clearfix">
                                <div class="checkbox text-center">
                                    <label>
                                        <input type="checkbox" name="agreement" id="user_agreement" value="true" checked="checked">同意<a target="_blank" href="/user_agreement">《&nbsp;<em class="logo">猫耳</em>&nbsp;用户协议》</a></label>
                                </div>
                            </div>
                            <input type="hidden" name="path" id="path" value="/discover">
                            <input type="hidden" name="redirect_from" id="redirect_from">
                            <div class="form-group form-actions">
                                <input type="submit" name="commit" value="注册" class="btn btn--blue_light" data-category="user" data-action="register" data-label="email">
                            </div>
                        </form>
                        <section class="auth">
                            <h6>使用社交账号登录</h6>
                            <p>
                              <a class="btn btn--icon btn--blue_light" title="用微信登录" data-category="user" data-action="login" data-label="wechat" href="/users/auth/wechat_web?state=%2Fdiscover"><i class="fa fa-weixin"></i></a>
                              <a class="btn btn--icon btn--blue_light" title="用微博登录" data-category="user" data-action="login" data-label="weibo" href="/users/auth/weibo?state=%2Fdiscover"><i class="fa fa-weibo"></i></a>
                            </p>
                        </section>
                        <footer class="section-footer"><a class="modal-flipper" href="#"><i class="fa fa-angle-left"></i>登录<em class="logo">猫耳</em></a></footer>
                    </div>
                </div>
            </div>
        </div>
    </div>
  </div>
  <!-- 登录model结束 -->
  </body>
  <script type="text/javascript">
    var api = {
        "loginUrl"    : '__APP__/User/login',
        "registerUrl" : '__APP__/User/register'
    };

    $(function() {
      $('.modal-flipper').click(function() {
        if($('.modal-dialog_wrapper').hasClass('is-flipped')) {
          $('.modal-dialog_wrapper').removeClass('is-flipped');
        } else {
          $('.modal-dialog_wrapper').addClass('is-flipped');
        }
      });

      //登录和注册#signin_form,
      $('#signup_form').submit(function() {
        var userName     = $("#user_name").val(),
            userEmail    = $('#user_email').val(),
            userPassword = $('#user_password').val(),
            code         = $('#captcha').val();

        $.post(api.registerUrl, { user_name:userName, user_email:userEmail, user_password :userPassword, code:code, redirect_url: window.location.href }, function(data) {
            console.log(data);
            if( data.status != 'succ') {
                alert(data.msg);return;
            }
            if(data.redirect_url) window.location.href = data.redirect_url;
        }, 'json')
        return false;
      });

      $('#login_form').submit(function() {
        var userPass = $('#login_password').val(),
            userEmail= $('#login_email').val();

        $.post(api.loginUrl, { user_pass: userPass, user_email:userEmail, redirect_url: window.location.href }, function(data) {
            console.log(data);
            if(!data.status) {
                alert(data.msg);
                return false;
            }
            if (data.redirect_url) window.location.href = data.redirect_url;
        }, 'json')
        //阻止默认事件
        return false;
      });

      $('.carousel').carousel();
    });
  </script>
</html>